pygame keys pressed

34

import pygame
events = pygame.event.get()
for event in events:
    if event.type == pygame.KEYDOWN:
        if event.key == pygame.K_LEFT:
            location -= 1
        if event.key == pygame.K_RIGHT:
            location += 1
keys = pygame.key.get_pressed()
if keys[K_LEFT]:
    print("left")

Comments

Submit
0 Comments